home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group02b.txt / 000019_icon-group-sender_Mon Aug 19 13:10:34 2002.msg < prev    next >
Internet Message Format  |  2003-01-02  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id g7JKAVk14542
  4.     for icon-group-addresses; Mon, 19 Aug 2002 13:10:31 -0700 (MST)
  5. Message-Id: <200208192010.g7JKAVk14542@baskerville.CS.Arizona.EDU>
  6. Date: Mon, 19 Aug 2002 15:56:04 +1200 (NZST)
  7. From: "Richard A. O'Keefe" <ok@cs.otago.ac.nz>
  8. To: icon-group@cs.arizona.edu, jenjhiz@yahoo.com
  9. Subject: Re: What about "Expressions?" (was Re: Icon Wish List)
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11. Status: RO
  12.  
  13. jenjhiz@yahoo.com (Gene Kahn) wrote:
  14.     This is not without its advantage, of course. In particular, in terms
  15.     of readability, I find that explicit variables allow my mind to
  16.     'close' (I'm not using it in the technical sense of "closure")
  17.     previous statements. On the other hand, in reading s-expression
  18.     languages like Lisp and Scheme, I find that I have to hold in my mind
  19.     too many _unstated_ intermediate results before I find what the
  20.     expression is all about.
  21.  
  22. You may be reading them in the wrong direction.
  23.  
  24.     FORTRAN-like
  25.     The man kicked the dog.
  26.     The dog chased the cat.
  27.     The cat bit the mouse.
  28.     The mouse died. 
  29.     
  30.     LISP-like (in infix notation)
  31.     The mouse the cat the dog the man kicked chased bit died.
  32.     
  33. As a Lisp programmer, I must say that doesn't look Lisp-like to me.
  34. Remember, Lisp puts the "verb" FIRST.
  35. Let's have a form (the (Variable) Condition) which binds Variable inside
  36. Condition and returns the thing that satifies Condition.
  37.   ;; 'the' is reserved in Common Lisp, so this must be Scheme!
  38.   (let* ((H (the (H)      (is-man H)))
  39.          (D (the (D) (and (is-dog D)   (kicked H D))))
  40.          (C (the (C) (and (is-cat C)   (chased D C))))
  41.          (M (the (M) (and (is-mouse M) (bit C M)))))
  42.     (died M))
  43.  
  44. This could also be written
  45.   (died (the (M) (and (is-mouse M)
  46.     (was bit M (the (C) (and (is-cat C)
  47.       (was chased C (the (D) (and (is-dog D)
  48.         (was kicked D (the (H) (is-man H))))))))))))
  49.  
  50. where (define (was f x y) (f y x))
  51.  
  52. As a Lisp programmer, I wouldn't be satisifed with either of these.
  53. I'd extend "the" to
  54.     ;; new form
  55.     (the (Variable Type) Cond1 ... Condk)
  56. =>  ;; old form
  57.     (the (Variable) (and (is-Type Variable) Cond1 ... Condk))
  58.  
  59. and write
  60.     (let* ((H (the (man H) #t))
  61.        (D (the (dog D) (kicked H D)))
  62.        (C (the (cat C) (chased D C)))
  63.        (M (the (mouse M) (bit C M))))
  64.       (died M))
  65. or
  66.     (died (the (mouse M) (was bit M
  67.             (the (cat C) (was chased C
  68.           (the (dog D) (was kicked D
  69.                 (the (man H)))))))))
  70.  
  71. "has died the mouse that was bit by the cat that was chased by
  72. the dog that was kicked by the man".
  73.  
  74.     Of course, variable-less, assignment-less languages have advantages. 
  75.     
  76. Indeed.  So of course does Icon.  The rule is always to use the language
  77. that best fits the easiest way to think correctly about the problem, and
  78. then translate into whatever your boss forces you to use.
  79.  
  80.